home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / userbox / publicdomain / vim-4.2 / src / keymap.h < prev    next >
Text File  |  1996-06-09  |  10KB  |  321 lines

  1. /* vi:set ts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved        by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  */
  8.  
  9. #define K_CCIRCM        0x1e    /* control circumflex */
  10.  
  11. /*
  12.  * For MSDOS some keys produce codes larger than 0xff. They are split into two
  13.  * chars, the first one is K_NUL (same value used in term.h).
  14.  */
  15. #define K_NUL            (0xce)        /* for MSDOS: special key follows */
  16.  
  17. /*
  18.  * Keycode definitions for special keys.
  19.  *
  20.  * Any special key code sequences are replaced by these codes.
  21.  */
  22.  
  23. /*
  24.  * K_SPECIAL is the first byte of a special key code and is always followed by
  25.  * two bytes.
  26.  * The second byte can have any value. ASCII is used for normal termcap
  27.  * entries, 0x80 and higher for special keys, see below.
  28.  * The third byte is guaranteed to be between 0x02 and 0x7f.
  29.  */
  30.  
  31. #define K_SPECIAL            (0x80)
  32.  
  33. /*
  34.  * characters 0x0000 - 0x00ff are "normal"
  35.  * characters 0x0100 - 0x01ff are used for abbreviations
  36.  * characters 0x0200 - 0xffff are special key codes
  37.  */
  38. #define IS_SPECIAL(c)        ((c) >= 0x200)
  39. #define IS_ABBR(c)            ((c) >= 0x100 && (c) < 0x200)
  40. #define ABBR_OFF            0x100
  41.  
  42. /*
  43.  * NUL cannot be in the input string, therefore it is replaced by
  44.  *        K_SPECIAL    KS_ZERO        K_FILLER
  45.  */
  46. #define KS_ZERO                255
  47.  
  48. /*
  49.  * K_SPECIAL cannot be in the input string, therefore it is replaced by
  50.  *        K_SPECIAL    KS_SPECIAL    K_FILLER
  51.  */
  52. #define KS_SPECIAL            254
  53.  
  54. /*
  55.  * KS_EXTRA is used for keys that have no termcap name
  56.  *        K_SPECIAL    KS_EXTRA    KE_xxx
  57.  */
  58. #define KS_EXTRA            253
  59.  
  60. /*
  61.  * KS_MODIFIER is used when a modifier is given for a (special) key
  62.  *        K_SPECIAL    KS_MODIFIER    bitmask
  63.  */
  64. #define KS_MODIFIER            252
  65.  
  66. /*
  67.  * These are used for the GUI
  68.  *         K_SPECIAL    KS_xxx        K_FILLER
  69.  */
  70. #define KS_MOUSE            251
  71. #define KS_MENU                250
  72. #define KS_SCROLLBAR        249
  73. #define KS_HORIZ_SCROLLBAR    248
  74.  
  75. /*
  76.  * Filler used after KS_SPECIAL and others
  77.  */
  78. #define K_FILLER            ('X')
  79.  
  80. /*
  81.  * translation of three byte code "K_SPECIAL a b" into int "K_xxx" and back
  82.  */
  83. #define TERMCAP2KEY(a, b)    ((a) + ((b) << 8))
  84. #define KEY2TERMCAP0(x)        ((x) & 0xff)
  85. #define KEY2TERMCAP1(x)        (((x) >> 8) & 0xff)
  86.  
  87. /*
  88.  * get second or third byte when translating special key code into three bytes
  89.  */
  90. #define K_SECOND(c)        ((c) == K_SPECIAL ? KS_SPECIAL : (c) == NUL ? KS_ZERO : KEY2TERMCAP0(c))
  91.  
  92. #define K_THIRD(c)        (((c) == K_SPECIAL || (c) == NUL) ? K_FILLER : KEY2TERMCAP1(c))
  93.  
  94. /*
  95.  * get single int code from second byte after K_SPECIAL
  96.  */
  97. #define TO_SPECIAL(a, b)    ((a) == KS_SPECIAL ? K_SPECIAL : (a) == KS_ZERO ? K_ZERO : TERMCAP2KEY(a, b))
  98.  
  99. /*
  100.  * Codes for keys that do not have a termcap name.
  101.  *
  102.  * K_SPECIAL KS_EXTRA KE_xxx
  103.  */
  104. #define KE_NAME            3            /* name of this terminal entry */
  105.  
  106. #define KE_S_UP            4
  107. #define KE_S_DOWN        5
  108.     
  109. #define KE_S_F1            6            /* shifted function keys */
  110. #define KE_S_F2            7
  111. #define KE_S_F3            8
  112. #define KE_S_F4            9
  113. #define KE_S_F5            10
  114. #define KE_S_F6            11
  115. #define KE_S_F7            12
  116. #define KE_S_F8            13
  117. #define KE_S_F9            14
  118. #define KE_S_F10        15
  119.  
  120. #define KE_S_F11        16
  121. #define KE_S_F12        17
  122. #define KE_S_F13        18
  123. #define KE_S_F14        19
  124. #define KE_S_F15        20
  125. #define KE_S_F16        21
  126. #define KE_S_F17        22
  127. #define KE_S_F18        23
  128. #define KE_S_F19        24
  129. #define KE_S_F20        25
  130.  
  131. #define KE_S_F21        26
  132. #define KE_S_F22        27
  133. #define KE_S_F23        28
  134. #define KE_S_F24        29
  135. #define KE_S_F25        30
  136. #define KE_S_F26        31
  137. #define KE_S_F27        32
  138. #define KE_S_F28        33
  139. #define KE_S_F29        34
  140. #define KE_S_F30        35
  141.     
  142. #define KE_S_F31        36
  143. #define KE_S_F32        37
  144. #define KE_S_F33        38
  145. #define KE_S_F34        39
  146. #define KE_S_F35        40
  147.  
  148. #define KE_MOUSE        41            /* mouse event start */
  149.  
  150.     /*
  151.      * Symbols for pseudo keys which are translated from the real key symbols
  152.      * above.
  153.      */
  154. #define KE_LEFTMOUSE    42            /* Left mouse button click */
  155. #define KE_LEFTDRAG        43            /* Drag with left mouse button down */
  156. #define KE_LEFTRELEASE    44            /* Left mouse button release */
  157. #define KE_MIDDLEMOUSE    45            /* Middle mouse button click */
  158. #define KE_MIDDLEDRAG    46            /* Drag with middle mouse button down */
  159. #define KE_MIDDLERELEASE 47            /* Middle mouse button release */
  160. #define KE_RIGHTMOUSE    48            /* Right mouse button click */
  161. #define KE_RIGHTDRAG    49            /* Drag with right mouse button down */
  162. #define KE_RIGHTRELEASE 50            /* Right mouse button release */
  163.  
  164. #define KE_IGNORE        51            /* Ignored mouse drag/release */
  165.  
  166. #define KE_TAB            52            /* unshifted TAB key */
  167. #define KE_S_TAB        53            /* shifted TAB key */
  168.  
  169. /*
  170.  * the three byte codes are replaced with the following int when using vgetc()
  171.  */
  172. #define K_ZERO            TERMCAP2KEY(KS_ZERO, K_FILLER)
  173.  
  174. #define K_UP            TERMCAP2KEY('k', 'u')
  175. #define K_DOWN            TERMCAP2KEY('k', 'd')
  176. #define K_LEFT            TERMCAP2KEY('k', 'l')
  177. #define K_RIGHT            TERMCAP2KEY('k', 'r')
  178. #define K_S_UP            TERMCAP2KEY(KS_EXTRA, KE_S_UP)
  179. #define K_S_DOWN        TERMCAP2KEY(KS_EXTRA, KE_S_DOWN)
  180. #define K_S_LEFT        TERMCAP2KEY('#', '4')
  181. #define K_S_RIGHT        TERMCAP2KEY('%', 'i')
  182. #define K_TAB            TERMCAP2KEY(KS_EXTRA, KE_TAB)
  183. #define K_S_TAB            TERMCAP2KEY(KS_EXTRA, KE_S_TAB)
  184.  
  185. #define K_F1            TERMCAP2KEY('k', '1')    /* function keys */
  186. #define K_F2            TERMCAP2KEY('k', '2')
  187. #define K_F3            TERMCAP2KEY('k', '3')
  188. #define K_F4            TERMCAP2KEY('k', '4')
  189. #define K_F5            TERMCAP2KEY('k', '5')
  190. #define K_F6            TERMCAP2KEY('k', '6')
  191. #define K_F7            TERMCAP2KEY('k', '7')
  192. #define K_F8            TERMCAP2KEY('k', '8')
  193. #define K_F9            TERMCAP2KEY('k', '9')
  194. #define K_F10            TERMCAP2KEY('k', ';')
  195.  
  196. #define K_F11            TERMCAP2KEY('F', '1')
  197. #define K_F12            TERMCAP2KEY('F', '2')
  198. #define K_F13            TERMCAP2KEY('F', '3')
  199. #define K_F14            TERMCAP2KEY('F', '4')
  200. #define K_F15            TERMCAP2KEY('F', '5')
  201. #define K_F16            TERMCAP2KEY('F', '6')
  202. #define K_F17            TERMCAP2KEY('F', '7')
  203. #define K_F18            TERMCAP2KEY('F', '8')
  204. #define K_F19            TERMCAP2KEY('F', '9')
  205. #define K_F20            TERMCAP2KEY('F', 'A')
  206.  
  207. #define K_F21            TERMCAP2KEY('F', 'B')
  208. #define K_F22            TERMCAP2KEY('F', 'C')
  209. #define K_F23            TERMCAP2KEY('F', 'D')
  210. #define K_F24            TERMCAP2KEY('F', 'E')
  211. #define K_F25            TERMCAP2KEY('F', 'F')
  212. #define K_F26            TERMCAP2KEY('F', 'G')
  213. #define K_F27            TERMCAP2KEY('F', 'H')
  214. #define K_F28            TERMCAP2KEY('F', 'I')
  215. #define K_F29            TERMCAP2KEY('F', 'J')
  216. #define K_F30            TERMCAP2KEY('F', 'K')
  217.  
  218. #define K_F31            TERMCAP2KEY('F', 'L')
  219. #define K_F32            TERMCAP2KEY('F', 'M')
  220. #define K_F33            TERMCAP2KEY('F', 'N')
  221. #define K_F34            TERMCAP2KEY('F', 'O')
  222. #define K_F35            TERMCAP2KEY('F', 'P')
  223.  
  224. #define K_S_F1            TERMCAP2KEY(KS_EXTRA, KE_S_F1)    /* shifted func. keys */
  225. #define K_S_F2            TERMCAP2KEY(KS_EXTRA, KE_S_F2)
  226. #define K_S_F3            TERMCAP2KEY(KS_EXTRA, KE_S_F3)
  227. #define K_S_F4            TERMCAP2KEY(KS_EXTRA, KE_S_F4)
  228. #define K_S_F5            TERMCAP2KEY(KS_EXTRA, KE_S_F5)
  229. #define K_S_F6            TERMCAP2KEY(KS_EXTRA, KE_S_F6)
  230. #define K_S_F7            TERMCAP2KEY(KS_EXTRA, KE_S_F7)
  231. #define K_S_F8            TERMCAP2KEY(KS_EXTRA, KE_S_F8)
  232. #define K_S_F9            TERMCAP2KEY(KS_EXTRA, KE_S_F9)
  233. #define K_S_F10            TERMCAP2KEY(KS_EXTRA, KE_S_F10)
  234.  
  235. #define K_S_F11            TERMCAP2KEY(KS_EXTRA, KE_S_F11)
  236. #define K_S_F12            TERMCAP2KEY(KS_EXTRA, KE_S_F12)
  237. #define K_S_F13            TERMCAP2KEY(KS_EXTRA, KE_S_F13)
  238. #define K_S_F14            TERMCAP2KEY(KS_EXTRA, KE_S_F14)
  239. #define K_S_F15            TERMCAP2KEY(KS_EXTRA, KE_S_F15)
  240. #define K_S_F16            TERMCAP2KEY(KS_EXTRA, KE_S_F16)
  241. #define K_S_F17            TERMCAP2KEY(KS_EXTRA, KE_S_F17)
  242. #define K_S_F18            TERMCAP2KEY(KS_EXTRA, KE_S_F18)
  243. #define K_S_F19            TERMCAP2KEY(KS_EXTRA, KE_S_F19)
  244. #define K_S_F20            TERMCAP2KEY(KS_EXTRA, KE_S_F20)
  245.  
  246. #define K_S_F21            TERMCAP2KEY(KS_EXTRA, KE_S_F21)
  247. #define K_S_F22            TERMCAP2KEY(KS_EXTRA, KE_S_F22)
  248. #define K_S_F23            TERMCAP2KEY(KS_EXTRA, KE_S_F23)
  249. #define K_S_F24            TERMCAP2KEY(KS_EXTRA, KE_S_F24)
  250. #define K_S_F25            TERMCAP2KEY(KS_EXTRA, KE_S_F25)
  251. #define K_S_F26            TERMCAP2KEY(KS_EXTRA, KE_S_F26)
  252. #define K_S_F27            TERMCAP2KEY(KS_EXTRA, KE_S_F27)
  253. #define K_S_F28            TERMCAP2KEY(KS_EXTRA, KE_S_F28)
  254. #define K_S_F29            TERMCAP2KEY(KS_EXTRA, KE_S_F29)
  255. #define K_S_F30            TERMCAP2KEY(KS_EXTRA, KE_S_F30)
  256.  
  257. #define K_S_F31            TERMCAP2KEY(KS_EXTRA, KE_S_F31)
  258. #define K_S_F32            TERMCAP2KEY(KS_EXTRA, KE_S_F32)
  259. #define K_S_F33            TERMCAP2KEY(KS_EXTRA, KE_S_F33)
  260. #define K_S_F34            TERMCAP2KEY(KS_EXTRA, KE_S_F34)
  261. #define K_S_F35            TERMCAP2KEY(KS_EXTRA, KE_S_F35)
  262.  
  263. #define K_HELP            TERMCAP2KEY('%', '1')
  264. #define K_UNDO            TERMCAP2KEY('&', '8')
  265.  
  266. #define K_BS            TERMCAP2KEY('k', 'b')
  267.  
  268. #define K_INS            TERMCAP2KEY('k', 'I')
  269. #define K_DEL            TERMCAP2KEY('k', 'D')
  270. #define K_HOME            TERMCAP2KEY('k', 'h')
  271. #define K_END            TERMCAP2KEY('@', '7')
  272. #define K_PAGEUP        TERMCAP2KEY('k', 'P')
  273. #define K_PAGEDOWN        TERMCAP2KEY('k', 'N')
  274.  
  275. #define K_MOUSE            TERMCAP2KEY(KS_MOUSE, K_FILLER)
  276. #define K_MENU            TERMCAP2KEY(KS_MENU, K_FILLER)
  277. #define K_SCROLLBAR        TERMCAP2KEY(KS_SCROLLBAR, K_FILLER)
  278. #define K_HORIZ_SCROLLBAR    TERMCAP2KEY(KS_HORIZ_SCROLLBAR, K_FILLER)
  279.  
  280. /*
  281.  * Symbols for pseudo keys which are translated from the real key symbols
  282.  * above.
  283.  */
  284. #define K_LEFTMOUSE            TERMCAP2KEY(KS_EXTRA, KE_LEFTMOUSE)
  285. #define K_LEFTDRAG            TERMCAP2KEY(KS_EXTRA, KE_LEFTDRAG)
  286. #define K_LEFTRELEASE        TERMCAP2KEY(KS_EXTRA, KE_LEFTRELEASE)
  287. #define K_MIDDLEMOUSE        TERMCAP2KEY(KS_EXTRA, KE_MIDDLEMOUSE)
  288. #define K_MIDDLEDRAG        TERMCAP2KEY(KS_EXTRA, KE_MIDDLEDRAG)
  289. #define K_MIDDLERELEASE        TERMCAP2KEY(KS_EXTRA, KE_MIDDLERELEASE)
  290. #define K_RIGHTMOUSE        TERMCAP2KEY(KS_EXTRA, KE_RIGHTMOUSE)
  291. #define K_RIGHTDRAG            TERMCAP2KEY(KS_EXTRA, KE_RIGHTDRAG)
  292. #define K_RIGHTRELEASE        TERMCAP2KEY(KS_EXTRA, KE_RIGHTRELEASE)
  293.  
  294. #define K_IGNORE            TERMCAP2KEY(KS_EXTRA, KE_IGNORE)
  295.  
  296. /* Bits for modifier mask */
  297. #define MOD_MASK_SHIFT        0x02
  298. #define MOD_MASK_CTRL        0x04
  299. #define MOD_MASK_ALT        0x08
  300. #define MOD_MASK_2CLICK        0x10
  301. #define MOD_MASK_3CLICK        0x20
  302. #define MOD_MASK_4CLICK        0x40
  303.  
  304. #define MOD_MASK_MULTI_CLICK    (MOD_MASK_2CLICK|MOD_MASK_3CLICK|MOD_MASK_4CLICK) 
  305.  
  306. /*
  307.  * The length of the longest special key name, including modifiers.
  308.  * Current longest is <M-C-S-4-MiddleRelease> (length includes '<' and '>').
  309.  */
  310. #define MAX_KEY_NAME_LEN    23
  311.  
  312. /* Maximum length of a special key event as tokens.  This includes modifiers.
  313.  * The longest event is something like <M-C-S-4-LeftDrag> which would be the
  314.  * following string of tokens:
  315.  *
  316.  * <K_SPECIAL> <KS_MODIFIER> bitmask <K_SPECIAL> <KS_EXTRA> <KT_LEFTDRAG>.
  317.  *
  318.  * This is a total of 6 tokens, and is currently the longest one possible.
  319.  */
  320. #define MAX_KEY_CODE_LEN    6
  321.